package alingrad.engine.objects;

import java.util.Iterator;
import java.util.LinkedList;

public class ObjectManager extends TreeNode {
	private LinkedList<TreeNode> mObjectList;

	public void load() {
		for (TreeNode node : mObjectList)
			node.load();
	}

	public ObjectManager() {
		super();
		mObjectList = new LinkedList<TreeNode>();
	}

	public void update(final long delta) {
		Iterator<TreeNode> iter = mObjectList.iterator();
		TreeNode object;
		while (iter.hasNext()) {
			object = iter.next();
			if (object.isValid())
				object.update(delta);
			else
				iter.remove();
		}
	}

	public void addObject(final TreeNode object) {
		mObjectList.add(object);
	}
}
